<template>
    <div class="mt-96">
        <div class="appeal-conv m-bodtom">
            <div class="appeal-titl">申诉原因</div>
            <div class="appeal-text">
                <textarea class="re-tarea" name="" cols="" rows="" id="description" placeholder="请输入申诉原因..."
                          maxlength="200" v-model="appealText">
                </textarea>
            </div>
        </div>
        <div class="rele-btn">
            <a class="active" @click="next">提交</a>
        </div>
    </div>
</template>

<script>
    export default {
        name: '',
        data () {
            return {
                appealText: '',
                postData: {},
                typeData: '',
            }
        },
        created(){
          if(this.$route.query.mainOrderNum || this.$route.query.mainOrderNum=='true'){
            this.typeData = 'levelingmainorder/complain';
          }else if (this.$route.query.type == 1) {
                this.typeData = 'playerOrder/playercomplain';
            } else {
                this.typeData = 'bullyOrder/bullycomplain';
            }
        },
        mounted(){
            this.$bus.emit('headerText', `我要申诉`);
        },
        destroyed(){
            this.$bus.emit('headerText', '');
        },
        methods: {
            next(){
                var self = this;
                if (self.appealText == "") {
                    self.$messagebox.alert('请输入申诉原因！');
                    return false;
                }
                self.postData.complainReason = self.appealText;
                if(self.$route.query.mainOrderNum){
                  self.postData.orderNo=self.$route.query.orderNum
                }else{
                  self.postData.orderNum = self.$route.query.orderNum;
                }
                if (self.$route.query.type != 4) {
                    self.$http.post(self.$CONSTANTS.APIdl + self.typeData, self.postData).then((res) => {
                        console.log(res);
                        if (res.body.responseStatus.code == "00") {
                          if(self.$route.query.mainOrderNum){
                            self.$router.push({
                              name: 'DlDsTransaction',
                              query: {orderNum: self.$route.query.orderNum, type: 2,mainOrderNum:self.$route.query.mainOrderNum}
                            })
                          }else if (self.$route.query.type == 2) {
                                self.$router.push({
                                    name: 'DlDsTransaction',
                                    query: {orderNum: self.$route.query.orderNum, type: 2}
                                })
                            } else {
                                self.$router.push({
                                    name: 'DlDsTransaction',
                                    query: {orderNum: self.$route.query.orderNum, type: 1}
                                })
                            }
                        } else {
                            self.$messagebox.alert(res.body.responseStatus.message);
                        }
                    }, (res) => {
                        console.log(res)
                    });
                } else {
                    self.$http.get(this.$CONSTANTS.APIStore + 'storeOrder/storeComplain', {
                        params: {
                            id: self.$route.query.orderNum,
                            bullyComplainReason: self.postData.complainReason
                        }
                    }).then((res) => {
                        if (res.body.responseStatus.code == "00") {
                            //location.href = '/vue/dl/member/dl-my-store/process';
                            if(this.$route.query.type==4){
                                self.$router.push({name:'DlSeller',params: {state: 'process'}})
                            }else{
                                 self.$router.push({name: 'DlMyStore', params: {state: 'process'}});
                            }
                           
                        }
                    }, (res) => {
                        console.log(res)
                    });
                }
            }
        }
    }
</script>

<style src="css/dlAll/dl-cxy.css" ></style>
<style scoped>

</style>
